package com.yutel.system.struts.extjs;

import java.util.HashMap;
import java.util.Map;

public class PanelUtils {
	public final static Map<String, String> DS_TYPE = new HashMap<String, String>();
	public final static Map<String, String> FORM_XTYPE = new HashMap<String, String>();
	public final static Map<String, String> FORM_LENGTH = new HashMap<String, String>();
	public final static Map<String, String> BUT_CN = new HashMap<String, String>();
	static
	{
		//dataStore type
		DS_TYPE.put("INT", "int");
		DS_TYPE.put("DATETIME", "datetime");
		DS_TYPE.put("FLOAT", "int");
		DS_TYPE.put("SHORT_STRING", "string");
		DS_TYPE.put("LONG_STRING", "string");
		DS_TYPE.put("MAX_STRING", "string");
		//formGrid type
		FORM_XTYPE.put("INT", "numberfield");
		FORM_XTYPE.put("DATETIME", "datefield");
		FORM_XTYPE.put("FLOAT", "numberfield");
		FORM_XTYPE.put("SHORT_STRING", "textfield");
		FORM_XTYPE.put("LONG_STRING", "textfield");
		FORM_XTYPE.put("MAX_STRING", "textarea");
		//formGrid length
		FORM_LENGTH.put("INT", "5");
		FORM_LENGTH.put("DATETIME", "20");
		FORM_LENGTH.put("FLOAT", "5");
		FORM_LENGTH.put("SHORT_STRING", "50");
		FORM_LENGTH.put("LONG_STRING", "200");
		FORM_LENGTH.put("MAX_STRING", "1000");
		// buttion china
		BUT_CN.put("ADD", "新增");
		BUT_CN.put("EDIT", "编辑");
		BUT_CN.put("DEL", "删除");
	}
	public static String dsType(String type){
		return (String)DS_TYPE.get(type.toUpperCase());
	}
	public static String xtype(String type){
		return (String)FORM_XTYPE.get(type.toUpperCase());
	}
	public static String formLength(String type){
		return (String)FORM_LENGTH.get(type.toUpperCase());
	}
	public static String butCN(String type){
		return (String)BUT_CN.get(type.toUpperCase());
	}
	public static boolean cn2Bool(String type){
		if("是".equals(type)) {
			return true;
		} else {
			return false;
		}
	}
}
